import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path' // 从 'path' 模块导入 resolve

// https://vite.dev/config/
export default defineConfig({
  plugins: [vue()],
  
  resolve: {
    alias: [
      { find: '@', replacement: path.resolve(__dirname, 'src') } // 使用 path.resolve 直接处理路径
    ],
  },

  server: {
    host: '0.0.0.0',
    port: 3000,
    proxy:{ //代理配置，解决跨域
      '/api':{
        target:'http://localhost:8080/BDMobieOps',  //获取路径中包含了api的请求
        changeOrigin:true,   //修改源
        rewrite:(path)=>path.replace(/^\/api/,'') //api替换为''
      }
    }
  },

})